---
layout: "default"
title: "withUnsafePointer"
description: "Swift documentation for 'withUnsafePointer': Invokes body with an UnsafePointer to arg and returns the."
keywords: "withUnsafePointer,func,swift,documentation"
root: "/v2.2"
---

<div class="declaration" id="func-withunsafepointer-t-result-inout_-t_-unsafepointer-t-throws-result">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-withunsafepointer-t-result-inout_-t_-unsafepointer-t-throws-result">func withUnsafePointer&lt;T, Result&gt;(<wbr>inout:<wbr> T,  _: UnsafePointer&lt;T&gt; throws -&gt; Result)</a>
        
<div class="comment collapse" id="comment-func-withunsafepointer-t-result-inout_-t_-unsafepointer-t-throws-result"><div class="p">
    <p>Invokes <code>body</code> with an <code>UnsafePointer</code> to <code>arg</code> and returns the
result. Useful for calling Objective-C APIs that take &quot;in/out&quot;
parameters (and default-constructible &quot;out&quot; parameters) by pointer.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func withUnsafePointer&lt;T, Result&gt;(inout arg: T, @noescape _ body: UnsafePointer&lt;T&gt; throws -&gt; Result) rethrows -&gt; Result</code>
    
    
</div></div>
</div>
